#!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
@Project : gtmsAutoTestProject 
@File    : food_api.py
@IDE     : PyCharm 
@Author  : Mario
@Date    : 2022/4/26 12:12 
@Describe: 菜品相关接口
"""
from APIs.posApi.base_pos_api import BasePosApi


class FoodApi(BasePosApi):

    def __init__(self, brandCode, environment):
        super().__init__(brandCode, environment)

    def food_list(self, businessType="1"):
        """
        获取门店菜品
        :param businessType: 业务类型(堂食-1,外带-2,外卖-3)
        :return:
        """
        payload = '{"businessType":"' + businessType + '"}'
        response = self.http_requests('food/list', payload)
        return response

    def food_taste_require_list(self, tasteCode: str, businessType="1"):
        """
        口味菜品的要求列表
        :param tasteCode: 口味编码
        :param businessType: 业务类型(堂食-1，外带-2，外卖-3)
        :return:
        """
        payload = '{"businessType": "' + businessType + '", "tasteCode": "' + tasteCode + '"}'
        response = self.http_requests('food/taste/require/list', payload)
        return response


if __name__ == '__main__':
    from Comm.tools.toolsControl import ToolsHandler

    test = FoodApi('823882', 'sit')
    response = test.food_list()
    food_list = ToolsHandler.get_json_result(response, "$..foodDetailList[?(@.discountFood==0)]")
    print(food_list)
